<?php
/**
 * User
 *
 * PHP version 5
 *
 * @category Controller
 * @version  1.0
 * @author   Duonght <hduongdmit@gmail.com>
 */
App::uses('AppController', 'Controller');
class ContactController extends AppController {

	const CAT_TYPE = "'static'";
	/**
	* Components
	* @var array
	*/
	public $components = array(
			'Paginator',
			'Upload',
			'Common',
	);
	public $helper = array('Utilities');
	public $uses = array('Contact', 'Category');
	private $categorymulti = array();
	private $stt = -1;

	public function beforeFilter(){
		parent::beforeFilter();
		$category_type = Configure::read('category_type');
		$this->set('category_type', $category_type);
	}

	public function index(){
		//get category parent
		$conditions = array(
				'type' => 1,
		);

		$paginate = array(
				'fields' => '*',
				'conditions' => $conditions,
				'order' => array(
					'last_update' => 'DESC',
				),
		);

		$this->Paginator->settings = $paginate;
		$listContact = $this->Paginator->paginate('Contact');
		//force view
		$this->set(array(
				'datas' => $listContact,
				'listCategory' => $this->categorymulti,
				'page_number_limit' => ConstAdminComponent::PAGE_NUMBER_LIMIT,
				'title_for_layout' => $this->moduleAdmin['Contact']['index'],
		));
	}

	public function register(){
		//get category parent
		$conditions = array(
				'type' => 2,
		);

		$paginate = array(
				'fields' => '*',
				'conditions' => $conditions,
				'order' => array(
						'last_update' => 'DESC',
				),
		);

		$this->Paginator->settings = $paginate;
		$listContact = $this->Paginator->paginate('Contact');
		//force view
		$this->set(array(
				'datas' => $listContact,
				'listCategory' => $this->categorymulti,
				'page_number_limit' => ConstAdminComponent::PAGE_NUMBER_LIMIT,
				'title_for_layout' => $this->moduleAdmin['Contact']['register'],
		));
	}
}
